package cn.eaay.stock.job;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class SimpleJobHandler {
    private static final Logger logger = LoggerFactory.getLogger(SimpleJobHandler.class);

    @XxlJob(value = "yjcJobHandler")
    public ReturnT<String> demoJobHandler(String param) throws InterruptedException {
        logger.info("param => {}", param);
        // 模拟业务执行
        for (int i = 0; i < 5; i++) {
            logger.info("Hello xxl-job {}", i);
            TimeUnit.SECONDS.sleep(2);
        }
        return ReturnT.SUCCESS;
    }
}
